package com.tkp.controller;

import com.tkp.config.UserTypeEnum;
import com.tkp.dao.UserMapper;
import com.tkp.entity.Bank;
import com.tkp.entity.User;
import com.tkp.interfaceU.AccountType;
import com.tkp.interfaceU.UserTypeContext;
import com.tkp.service.UserPayService;
import com.tkp.token.CheckToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;

/**
 * @Author: duk
 * @Date: 2021/10/29 15:12
 * @Description: 用户信息操作接口
 */
@RestController
@Api("用户信息操作接口")
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserTypeContext userTypeContext;
    @Resource
    private UserMapper userMapper;

    @ApiOperation("获取最终优惠价格")
    @CheckToken()
    @GetMapping(value = "/getUserQuotePrice")
    public BigDecimal getUserQuotePrice(BigDecimal price){
        UserPayService userService;
        userService = userTypeContext.getUserService(UserTypeEnum.COMMON_USER);
        return userService.quotePrice(price);
    }

    @ApiOperation("获取用户银行卡信息")
    @PostMapping("/getBank")
    public Bank getBankData(@Valid @RequestBody User user){
        Bank bank = new Bank();
        bank.setAccountName("中国建设银行");
        bank.setAccountCode("12344342323333");
        bank.setAccountType(AccountType.BANK_CARD_CREDIT);
        return bank;
    }

}
